package com.ruoyi.bizsys.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.ruoyi.bizsys.domain.IncreasedLimitList;
import com.ruoyi.bizsys.service.IIncreasedLimitListService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ObjectUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 提额名单Controller
 *
 * @author african-loan
 * @date 2021-07-03
 */
@RestController
@RequestMapping("/bizsys/increasedLimitList")
public class IncreasedLimitListController extends BaseController {
    @Autowired
    private IIncreasedLimitListService increasedLimitListService;

    /**
     * 查询提额名单列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:list')")
    @GetMapping("/list")
    public TableDataInfo list(IncreasedLimitList increasedLimitList) {
        startPage();
        List<IncreasedLimitList> list = increasedLimitListService.selectIncreasedLimitListList(increasedLimitList);
        return getDataTable(list);
    }

    /**
     * 导出提额名单列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:export')")
    @Log(title = "提额名单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IncreasedLimitList increasedLimitList) {
        List<IncreasedLimitList> list = increasedLimitListService.selectIncreasedLimitListList(increasedLimitList);
        ExcelUtil<IncreasedLimitList> util = new ExcelUtil<IncreasedLimitList>(IncreasedLimitList.class);
        return util.exportExcel(list, "increased_limit_list");
    }

    /**
     * 获取提额名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(increasedLimitListService.selectIncreasedLimitListById(id));
    }

    /**
     * 新增提额名单
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:add')")
    @Log(title = "提额名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IncreasedLimitList increasedLimitList) {
        return toAjax(increasedLimitListService.insertIncreasedLimitList(increasedLimitList));
    }

    /**
     * 修改提额名单
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:edit')")
    @Log(title = "提额名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IncreasedLimitList increasedLimitList) {
        return toAjax(increasedLimitListService.updateIncreasedLimitList(increasedLimitList));
    }

    /**
     * 删除提额名单
     */
    @PreAuthorize("@ss.hasPermi('bizsys:increased_limit_list:remove')")
    @Log(title = "提额名单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(increasedLimitListService.deleteIncreasedLimitListByIds(ids));
    }
}
